# Maintainer:

_realname=lib3mf
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}-devel")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}-devel")
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-devel")
pkgver=2.0.0
pkgrel=1
pkgdesc='Lib3MF is the reference implementation of the 3D Manufacturing Format file standard http://3mf.io'
arch=('any')
url='https://github.com/3MFConsortium/lib3mf'
license=('BSD 2-Clause')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=(!staticlibs strip)
source=("${_realname}-${pkgver}.tar.gz"::"${url}/archive/v${pkgver}.tar.gz"
        01_install_component.patch)
sha256sums=('453588414c8e25668651de678a492632c1e5715e8ff3fdbb6a034fc57b14440b'
            'e8035f9b0d2262aca2dd94cda010264216f80c1e0ef0e7098860f0f7144996d8')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}"/01_install_component.patch
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"
  
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G "MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DLIB3MF_TESTS=OFF \
    ../${_realname}-${pkgver}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
